﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using AlexandriaPressUserBusinessLayer;


namespace AlexandriaPressWebsite.MasterPages.UserPages
{
    public partial class UserProfilePage : System.Web.UI.Page
    {
        protected void Page_Init(object sender, EventArgs e)
        {
            UserBusinsessLayer business = new UserBusinsessLayer();
            string _UserType = business.getUserType(HttpContext.Current.User.Identity.Name);
            if (_UserType == "Type_Buyer" || _UserType == "Type_Admin" || _UserType == "Type_ProofReader" || _UserType == "Type_Author")
            {

            }
            else
            {
                Response.Redirect("~/MasterPages/ErrorPage.aspx");
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (User.Identity.IsAuthenticated)
            {
                
                if (Session["blocked"] != null)
                {
                    Session.RemoveAll();
                    Response.Redirect("~/MasterPages/MainPage.aspx");
                }

                string username = HttpContext.Current.User.Identity.Name;
                UserBusinsessLayer business = new UserBusinsessLayer();
                DataTable table = business.profileView(business.myProfile(username));
                myProfileDetailsView1.DataSource = table;
                myProfileDetailsView1.EmptyDataText = "Profile information cannot be displayed.";
                myProfileDetailsView1.DataBind();
            }
            else
            {
                Response.Redirect("~/MasterPages/MainPage.aspx");
            }
        }

        protected void editAccountButton_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/MasterPages/UserPages/EditAccountPage.aspx");
        }

        protected void changePasswordButton_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/MasterPages/UserPages/ChangePasswordPage.aspx");
        }

    
    }
}
